<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //默认值的生效条件
        // 不传递参数或者明确的传递undefined参数 只有这两种情况下 默认值才会生效
        //   const multiply = (x, y = 1) => x * y
        //   console.log(multiply(2, 0)); //0
        //   console.log(multiply(2, null)); //0
        //   console.log(multiply(2, undefined)); //2
        //函数参数的默认值 最好从列表的右边开始
        // const multiply = (x = 1, y) => x * y;
        // console.log(multiply(undefined, 2)); //2

        const multiply = (x, y = 1) => x * y;
        console.log(multiply(2)); //2
    </script>
</body>

</html>